package com.xujiang.myblog.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

/**
 * Created by xujiang on 2017/4/26.
 */

public class DlogAdapter extends BaseListAdapter<String>{

    public DlogAdapter(Context context,List<String> list) {
        super(context,list);
    }

    @Override
    public View getItemView(String item, int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = inflate(android.R.layout.simple_spinner_dropdown_item, parent, false);
            holder = new ViewHolder(convertView);
            holder.setTag();
        } else {
            holder = ViewHolder.getTag(convertView);
        }
        holder.onHandle(item, position);
        return convertView;
    }

    class ViewHolder extends BaseViewHolder<String> {
        TextView textView;

        public ViewHolder(View itemView) {
            super(itemView);
            textView = findViewById(android.R.id.text1);
        }

        @Override public void onHandle(String item, int position) {
            textView.setText(item);
        }
    }
}
